﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JCNT.DAL;
using System.IO;
using Pub;

namespace JCNT.NoteApp
{
    public partial class FDebug : Form
    {
        CADO ado1 = new CADO();
        CTreeII ctree = new CTreeII();
        Cwp_note wp_node;
        CPic cpic = new CPic();
        Cwp_pic wp_pic;
        public FDebug()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            int i = 0;
            string strSQL = "Select ID,Tit,Lab,RootID from wp_note ";
            DataSet ds1 = ado1.sel1(strSQL);
            int n = ds1.Tables[0].Rows.Count;
            foreach (DataRow dr1 in ds1.Tables[0].Rows)
            {
                i++;
                label1.Text = i.ToString() + "/" + n.ToString();

                //string ID = dr1["ID"].ToString();
                //wp_node = ctree.get_wp_note(ID);
                //Program.fmain.fillRchText(ID, Program.fmain.tboxCon);
                //wp_node.Con = Program.fmain.tboxCon.Text;
                //ctree.noteEdt(wp_node);
                //ctree.conEdt(ID, Program.fmain.tboxCon);
            }
            
        }

        private void btnPic_Click(object sender, EventArgs e)
        {
            string strSQL = "select id,nam from wp_pic";
            DataSet ds1 = ado1.sel1(strSQL);
            foreach (DataRow dr in ds1.Tables[0].Rows)
            {
                try
                {
                    string ID = dr["ID"].ToString();
                    //CPub.Send(ID);
                    Image img1 = cpic.getPic(ID);
                    MemoryStream stream1 = new MemoryStream();
                    img1.Save(stream1, System.Drawing.Imaging.ImageFormat.Jpeg);
                    img1 = Image.FromStream(stream1);
                    cpic.picEdt(ID, img1);
                }
                catch (System.Exception ex)
                {
                    CPub.Send(ex.ToString());	
                }

            }
        }
    }
}
